package bz.yfw.example.s3blazeds.part2.helper
{
	import bz.yfw.example.s3blazeds.part2.model.view.EmpViewModel;
	import bz.yfw.example.s3blazeds.part2.view.EmpEditCameraView;
	
	import org.seasar.akabana.yui.framework.ns.viewpart;
	
	import spark.components.supportClasses.ViewReturnObject;
	import spark.primitives.BitmapImage;
	
	use namespace viewpart;

	/**
	 * 写真撮影初期化用Helper
	 * @author tokufxug http://twitter.com/tokufxug
	 */
	public class EmpEditCameraInitHelper
	{
		public var view:EmpEditCameraView;
		viewpart var bmpimgShashin:BitmapImage;
		
		public function get empViewModel():EmpViewModel {
			var retObj:ViewReturnObject = view.navigator.poppedViewReturnedObject;
			
			if (retObj && retObj.object) {
				return retObj.object as EmpViewModel;
			}
			
			if (view.data && view.data is EmpViewModel) {
				return view.data as EmpViewModel;
			}
			return null;
		}
		
		public function reflectEmpModel():void {
			var vm:EmpViewModel = empViewModel;
			if (!vm) {
				return;
			}
			bmpimgShashin.source = vm.shashin;
			view.viewModel = vm;
		}
	}
}